package android.gpstrac.app;

import android.app.Activity;
import android.database.Cursor;
import android.gpstrac.R;
import android.gpstrac.data.User.UserContent;
import android.gpstrac.data.UserLocation.UserLocationContent;
import android.os.Bundle;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.SimpleCursorAdapter;
import android.widget.TextView;

public class GPSTracFriendHistApp extends Activity {
	
	private Cursor c;
	public void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		
		setContentView(R.layout.user_history);
		
		String contactName = this.getIntent().getStringExtra("wUserHist");
		
		TextView tv = (TextView)findViewById(R.id.contactName);
		tv.setText("Friend: " + contactName);
		
		c = this.getContentResolver().query(UserLocationContent.CONTENT_URI, null, UserLocationContent.USER + "='" + contactName + "'", null, UserLocationContent.SEQ + " ASC");
		startManagingCursor(c);
		
		ListAdapter adapter = new SimpleCursorAdapter(
				this, 
				R.layout.list_item2, 
				c, 
				new String[] { UserLocationContent.SEQ, UserLocationContent.LAT, UserLocationContent.LONG }, 
				new int[] { R.id.contact_seq, R.id.contact_latitude, R.id.contact_longitude });
		
		final ListView list = (ListView)findViewById(R.id.contactHistory);
		list.setAdapter(adapter);
	}
}
